package com.dongwu.manager.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dongwu.common.dto.Result;
import com.dongwu.common.utils.Exceptions;
import com.dongwu.common.web.BaseController;
import com.dongwu.manager.entity.Market;
import com.google.common.base.Splitter;
/**
 * 营销工具
 * @author xyj
 *
 */
@Controller
@RequestMapping("/manager/market")
public class MarketController extends BaseController<Market, String> {
	@Value("${dongwu.marketClassify}")
	private String marketClassify;
	
	/**
	 * 处理多对多中间表数据问题
	 */
//	@ModelAttribute
//	public void getEntity(@RequestParam(value = "id", defaultValue = "-1") String id, Model model) {
//		if (!String.valueOf(id).equals("-1")) {
//			Market market = baseService.get(id);
//			market.getDevice().clear();
//			model.addAttribute("entity", market);
//		}
//	}
	/**
	 *
	 * @return
	 */
	@RequestMapping(value = "/selectMarketClassify")
	@ResponseBody
	public Result selectcity() {
		try {
			List<String> marketClassifyRes = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(marketClassify);

			return Result.successResult(marketClassifyRes);

		} catch (Exception e) {
			String msg = Exceptions.getMessage(e);
			logger.error(msg, e);
			return Result.errorResult(msg);
		}

	}
}
